<%@page import="guest.GuestVo"%>
<%@page import="guest.Guest"%>
<%@page import="java.util.Vector"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>list.jsp</title>
<style>

#bookmain{
	
	margin:auto;
	width:695px;
}
#list_body{
	text-align:center;
}
#list_serial{display:inline-block;width:80px;background-color: #ffbbff;}

#list_content, #list_mdate, #list_mid, #list_subject{display:inline-block;width:200px;background-color: #bbffcc;}


.item_serial{display:inline-block;width:80px;}
.item_mid{display:inline-block;width:200px;}
.item_subject{display:inline-block;width:200px;}
.item_content{display:inline-block;width:200px;}
.item_mdate{display:inline-block;width:200px;}
#Cnt{
	width:480px;
}
#write{
	margin-left:640px;
}
#Cnt,#find_div{
	display:inline-block;
}
a{
	text-decoration:none;
	color:#118833;
}
a:hover{
	text-decoration:underline;
	text-shadow:2px 2px 2px #bbaaaa;
}

</style>
<script>
function getId(id){ return document.getElementById(id)}
function init(){
	getId('btnfind').onclick=findFunc;
	getId('find').onkeyup=function(ev){
		if(ev.keyCode == 13) findFunc;
	}
	getId('btnwrite').onclick=function(){
		location.href='MyHome.jsp?inc_content=./guest/insert.jsp';
	}
}
function findFunc(){
	var find = getId('find').value;
	location.href='MyHome.jsp?inc_content=./guest/list.jsp&find='+find;
}


</script>
</head>
<body>
<jsp:useBean id="vo" class="guest.GuestVo" scope="page"/>
<jsp:setProperty property="*" name="vo"/> 

<% 
request.setCharacterEncoding("utf-8");

Guest g = new Guest();
g.setVo(vo);
Vector<GuestVo> v = g.booklist(); %>

<div id='bookmain'>
<h1>게시판 현황</h1>

<div id='Cnt'>
<label>총게시글수 : <%=v.size()%></label>
<output id='bookCnt'>
<%-- <%
for(int i=0; i<v.size(); i++){
	int cnt =+ i;
}
%> --%>

</output>
</div>
<div id='find_div'>
	<input type='search' id='find'  name='find' value='<%=vo.getFind()%>'>
	<input type='button' id='btnfind' value='검색'>

</div>

<div id='list_body'>
	<div id='list_title'>
		<div id='list_serial'>게시번호</div>
		<div id='list_subject'>제목</div>
		<div id='list_mid'>아이디</div>
		<div id='list_mdate'>게시시간</div>
	</div>
	<%
	for(int i=0; i<v.size() ; i++){ 
		GuestVo gv = v.get(i);
	
	%>
	
	<div class='list_item'>
		<div class='item_serial'><%=gv.getSerial() %></div>
		<div class='item_subject'>
			<a href='MyHome.jsp?inc_content=./guest/modify.jsp&serial=<%=gv.getSerial()%>'><%=gv.getSubject() %></a>
		</div>
		<div class='item_mid'><%=gv.getMid() %></div>
		<div class='item_mdate'><%=gv.getMdate() %></div>
	</div>

	<% } %>
</div>
<hr/>
<div id='write'>
<input type='button' id='btnwrite' value='글쓰기'>
</div>
</div>
<script>init();</script>
</body>
</html>